package hasalah.demo.client.views;


import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class ActivityMainComposite extends Composite {

	private RootPanel rootPanel;
	
	public ActivityMainComposite() {
		
		rootPanel = RootPanel.get();
		
		rootPanel.add(getHyperLinks());
		
		initWidget(this);
		
	}
	
	@SuppressWarnings( "deprecation" )
	private IsWidget getHyperLinks() {

/*		Hyperlink economyLink = new Hyperlink("Define Economy","economy");
		
		economyLink.addClickHandler(new ClickHandler() {
			
			public void onClick(ClickEvent event) {

				DefaultPanel defaultPanel = new DefaultPanel("Econmony Configuration ..");
				
				defaultPanel.setBody(new EconomyConfigurationComposite());				
				
				
				rootPanel.add(defaultPanel.getMe());
				
			}
		});*/

		final Hyperlink activityLink = new Hyperlink("Check-in Activity","checkin");
		
		activityLink.addClickHandler(new ClickHandler() {
			
			public void onClick(ClickEvent event) {

				PopupPanel panel = new PopupPanel(false);
				
				panel.setAnimationEnabled(true);
				panel.setGlassEnabled(true);
				panel.setTitle("Check-in Activity Configuration");
				panel.setPopupPosition(200, 50);
				
				
				PopupDefaultPanel defaultPanel = new PopupDefaultPanel("Check-in ..");
				
				defaultPanel.setBody(new CheckinActivityCompsite());				
				
				defaultPanel.setPopupPanel(panel);
				panel.setWidget(defaultPanel.getMe());
				
				panel.show();
				
			}
		});

		Hyperlink levelLink = new Hyperlink("Conversion Activity ","conver");
		
		levelLink.addClickHandler(new ClickHandler() {
			
			public void onClick(ClickEvent event) {

				PopupPanel panel = new PopupPanel(false);
				
				panel.setAnimationEnabled(true);
				panel.setGlassEnabled(true);
				panel.setTitle("Conversion Activity Configuration");
				panel.setPopupPosition(300, 100);
				
				PopupDefaultPanel defaultPanel = new PopupDefaultPanel("Conversion ..");
				
				defaultPanel.setBody(new ConversionActivityCompsite());				
				
				defaultPanel.setPopupPanel(panel);
				panel.setWidget(defaultPanel.getMe());
				
				panel.show();
				
			}
		});

		Hyperlink placeLink = new Hyperlink("Sharing Activity","share");
		
		placeLink.addClickHandler(new ClickHandler() {
			
			public void onClick(ClickEvent event) {

				PopupPanel panel = new PopupPanel(false);
				
				panel.setAnimationEnabled(true);
				panel.setGlassEnabled(true);
				panel.setTitle("Sharing Activity Configuration");
				panel.setPopupPosition(300, 100);
				
				PopupDefaultPanel defaultPanel = new PopupDefaultPanel("Sharing ..");
				
				defaultPanel.setBody(new SharingActivityCompsite());				
				
				defaultPanel.setPopupPanel(panel);
				panel.setWidget(defaultPanel.getMe());
				
				panel.show();
				
			}
		});

		Hyperlink positionLink = new Hyperlink("SMS Activity","sms");
		
		positionLink.addClickHandler(new ClickHandler() {
			
			public void onClick(ClickEvent event) {
				
				PopupPanel panel = new PopupPanel(false);
				
				panel.setAnimationEnabled(true);
				panel.setGlassEnabled(true);
				panel.setTitle("SMS Activity Configuration");
				panel.setPopupPosition(300, 100);
				
				PopupDefaultPanel defaultPanel = new PopupDefaultPanel("SMS ..");
				
				defaultPanel.setBody(new SMSActivityCompsite());				
				
				defaultPanel.setPopupPanel(panel);
				panel.setWidget(defaultPanel.getMe());
				
				panel.show();
				
			}
		});

		Hyperlink rewardLink = new Hyperlink("Voting Activity","vote");
		
		rewardLink.addClickHandler(new ClickHandler() {
			
			public void onClick(ClickEvent event) {
				
				PopupPanel panel = new PopupPanel(false);
				
				panel.setAnimationEnabled(true);
				panel.setGlassEnabled(true);
				panel.setTitle("Voting Activity Sample");
				panel.setPopupPosition(300, 100);
				
				PopupDefaultPanel defaultPanel = new PopupDefaultPanel("Voting ..");
				
				defaultPanel.setBody(new VotingActivityComposite());				
				
				defaultPanel.setPopupPanel(panel);
				panel.setWidget(defaultPanel.getMe());
				
				panel.show();
				
			}
		});

		
		final VerticalPanel panel = new VerticalPanel();
		
		/*panel.add(economyLink);*/
		
		final CheckBox addCheckin = new CheckBox();
		addCheckin.setText("Add Checkin Activity");
		addCheckin.setValue(true);
		
		CheckBox addSurvey = new CheckBox();
		addSurvey.setText("Add Survey Activity");
		addSurvey.setValue(true);

		
		CheckBox addConversion = new CheckBox();
		addConversion.setText("Add Buying Activity");
		addConversion.setValue(true);

		panel.add(addCheckin);
		
		panel.add(addSurvey);
		
		panel.add(addConversion);
		
		addCheckin.addClickHandler(new ClickHandler() {
			

			public void onClick(ClickEvent event) {

				if(addCheckin.getValue().equals(false)) {
					
					panel.remove(activityLink);
				
				} else {
					
					panel.add(activityLink);
					
				}
				
			}
		});
		
		panel.add(activityLink);
		panel.add(levelLink);
		panel.add(placeLink);
		panel.add(positionLink);
		panel.add(rewardLink);
		
		return panel;
		
	}

}
